package com.tarena.lbs.business.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tarena.lbs.business.pojo.po.StorePO;
import org.apache.ibatis.annotations.Delete;
import com.tarena.lbs.business.pojo.query.AreaStoreQuery;
import com.tarena.lbs.business.pojo.vo.StoreVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StoreMapper extends BaseMapper<StorePO> {


    @Delete("delete from tarena_lbs_business.lbs_store where id = #{id}")
    int delete(Integer id);

    @Update("update lbs_store set store_status = if(store_status='0','1','0') where id = #{id}")
    int updateStatus(Integer id);

    @Select("<script>" +
            "select * from lbs_store " +
            "where city_id in " +
            "<foreach collection='cityIdList' item='cityId' open='(' separator=',' close=')'>" +
            "#{cityId}" +
            "</foreach>" +
            "</script>")
    List<StoreVO> getStoreByCity(AreaStoreQuery query);
}
